package com.hcy.driver.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hcy.driver.DriverPageInfoBz;
import com.hcy.driver.dto.request.BaseInfoRequestDTO;
import com.hcy.driver.dto.response.BaseInfoResponseDTO;
import com.hcy.driver.entity.Info;
import com.hcy.driver.mapper.InfoMapper;
import com.hcy.driver.service.ICarInfoService;
import com.hcy.driver.service.IInfoService;
import com.hcy.ordermodel.dto.response.HomeInfoResponseDTO;
//import com.hcy.common.dto.response.MessageResponseDTO;
import com.hcy.orderclient.OrderForDriverClient;
import com.hcy.ordermodel.dto.request.HomeInfoRequestDTO;
import com.hcy.rabbitbasicmodel.enums.Code;
import com.hcy.rabbitbasicmodel.enums.PushType;
import com.hcy.rabbitbasicmodel.model.ResponseData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Author huchenying
 * @Description
 * @Date 2021/12/27 15:00
 */
@Service
public class DriverPageInfoBzImpl implements DriverPageInfoBz {

    Logger logger = LoggerFactory.getLogger(DriverPageInfoBzImpl.class);

    @Autowired
    OrderForDriverClient orderForDriverClient;

    @Autowired
    IInfoService infoService;

    @Resource
    InfoMapper infoMapper;

    @Override
    public BaseInfoResponseDTO getCarInfo(BaseInfoRequestDTO requestDTO) {
        return infoMapper.getBaseInfo(requestDTO);
    }

    @Autowired
    ICarInfoService carInfoService;

    /**
     * @Author huchenying
     * @Description 获取司机端首页的信息
     * @Date  2021/12/27 15:02
     **/
    @Override
    public HomeInfoResponseDTO doHomeInfo(HomeInfoRequestDTO requestDTO) {
        //获取今日单量和今日流水
        //获取当前服务单
        //获取当前预约单
        ResponseData<HomeInfoResponseDTO> responseDTO = orderForDriverClient.findDriverHomeInfo(requestDTO);
        if(responseDTO.getCode() != Code.Success){
            throw new RuntimeException("获取订单信息失败！");
        }
        //获取出车信息和是否登录车载端信息
        HomeInfoResponseDTO data = responseDTO.getData();
        HomeInfoResponseDTO carInfo = carInfoService.getCarInfo(requestDTO);
        data.setIsLoginClient(carInfo.getIsLoginClient());

        //TODO 获取最新一条消息
//        MessageResponseDTO messageResponseDTO = new MessageResponseDTO();
//        messageResponseDTO.setTitle("测试");
//        messageResponseDTO.setContent("这是一条测试信息");
//        messageResponseDTO.setPushType(PushType.SYSTEM.getCode());
//        messageResponseDTO.setSendTime(new Date());
//        data.setNews(messageResponseDTO);
        return data;
    }
}
